/*
 *  AudioFilePlayer.h
 *  Fender_Installation
 *
 *  Created by David Rowland on 10/01/2009.
 *  Copyright 2009 UWE. All rights reserved.
 *
 */

#ifndef AUDIOFILEPLAYER_H
#define AUDIOFILEPLAYER_H

#include <juce/juce.h>

class AudioFilePlayer	:	public AudioTransportSource,
							public TextButton
{
public:
	/// create an empty AudioFilePlayer
	AudioFilePlayer();
	
	/// create an AudioFilePlayer from a given path
	/// and a text button to represent it
	AudioFilePlayer(const String& path,
					String buttonText =String::empty,
					String toolTip =String::empty);
	
	~AudioFilePlayer();
	
	/// Play the audio file from the start
	void startFromZero();
	
	/// Simple function to pause the audio file
	void pause();
	
	/// Open and get ready to play a given audio file path
	bool setFile(const String& path);
	
	
	String fileName;
	
private:	
	/// Create the reader from a given path
	AudioFormatReader* audioFormatReaderFromFile(const String& path);
	
	// this is the actual stream that's going to read from the audio file.
	AudioFormatReaderSource* currentAudioFileSource;
};

#endif //AUDIOFILEPLAYER_H